{% extends 'df_goods/gbase.html' %}
{% block head %}
    <script>
        $(function () {
            $('.add_goods').click(function () {
                let gid = $(this).prop('name')
                $.get('/cart/add/', {'gid': gid, 'count': 1}, function (data) {
                    if (data.isLogin == 0) {
                        location.href = '/user/login/'
                    }
                    if (data.ok === 1) {
                        window.location.reload();
                    }
                })
            })
        })
    </script>
{% endblock %}
{% block nav %}
    <div class="breadcrumb">
        <a href="#">全部分类</a>
        <span>></span>
        <a href="#">{{ type.ttitle }}</a>
    </div>

{% endblock %}


{% block right %}


    <div class="sort_bar">
        <a href="/list{{ type.id }}_{{ page.number }}_0" {% if ord == '0' %}class="active" {% endif %}>默认</a>
{#        <a href="/list{{ type.id }}_{{ page.number }}_3" {% if ord == '3' %}class="active" {% endif %}>默认</a>#}
        <a href="/list{{ type.id }}_{{ page.number }}_1" {% if ord == '1' %}class="active" {% endif %}>价格</a>
{#        <a href="/list{{ type.id }}_{{ page.number }}_4" {% if ord == '4' %}class="active" {% endif %}>价格</a>#}
        <a href="/list{{ type.id }}_{{ page.number }}_2" {% if ord == '2' %}class="active" {% endif %}>人气</a>
{#        <a href="/list{{ type.id }}_{{ page.number }}_5" {% if ord == '5' %}class="active" {% endif %}>人气</a>#}
    </div>

    <ul class="goods_type_list clearfix">
        {% for g in page.object_list %}
            <li>
                <a href="/{{ g.id }}"><img src="/static/images/{{ g.gpic }}"></a>
                <h4><a href="/{{ g.id }}">{{ g.gtitle }}</a></h4>
                <div class="operate">
                    <span class="prize">￥{{ g.gprice }}</span>
                    <span class="unit">{{ g.gprice }}/{{ g.gunit }}</span>
                    <a href="#" class="add_goods" title="加入购物车" name="{{ g.id }}"></a>
                </div>
            </li>
        {% endfor %}

    </ul>

    <div class="pagenation">

        {% if page.has_previous %}

            <a href="/list{{ type.id }}_{{ page.previous_page_number }}_{{ ord }}">
                上一页
            </a>
        {% endif %}

        {% for i in page.paginator.page_range %}
            {% if i == page.number %}
                <a href="#" class="active">{{ i }}</a>
            {% else %}
                <a href="/list{{ type.id }}_{{ i }}_{{ ord }}">{{ i }}</a>

            {% endif %}

        {% endfor %}

        {% if page.has_next %}
            <a href="/list{{ type.id }}_{{ page.next_page_number }}_{{ ord }}">下一页></a>
        {% endif %}


    </div>
{% endblock %}